package com.chenyijie;

import com.chenyijie.pojo.MyRemoteObject;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.rpc.IRemoteObject;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

public class ServiceAbility extends Ability {
    private static final HiLogLabel LABEL_LOG = new HiLogLabel(HiLog.LOG_APP, 0x00001, ServiceAbility.class.getSimpleName());

    MyRemoteObject remoteObject = null;

    @Override
    public void onStart(Intent intent) {
        HiLog.info(LABEL_LOG, "ServiceAbility::onStart");
        super.onStart(intent);

        remoteObject = new MyRemoteObject();
    }

    @Override
    public void onBackground() {
        super.onBackground();
        HiLog.info(LABEL_LOG, "ServiceAbility::onBackground");
    }

    @Override
    public void onStop() {
        super.onStop();
        HiLog.info(LABEL_LOG, "ServiceAbility::onStop");
    }

    @Override
    public void onCommand(Intent intent, boolean restart, int startId) {
        HiLog.info(LABEL_LOG, "ServiceAbility::onCommand");
    }

    @Override
    public IRemoteObject onConnect(Intent intent) {
        super.onConnect(intent);
        HiLog.info(LABEL_LOG, "ServiceAbility::onConnect");
        return remoteObject.asObject();
    }

    @Override
    public void onDisconnect(Intent intent) {
        HiLog.info(LABEL_LOG, "ServiceAbility::onDisconnect");
    }
}